package tcu.iot.gasmanage.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tcu.iot.gasmanage.common.Result;
import tcu.iot.gasmanage.entity.baidumap.AllPointsInfo;
import tcu.iot.gasmanage.entity.baidumap.AllPointsInfoReturn;
import tcu.iot.gasmanage.mapper.BaiduMapMapper;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class BaiduMapService {

    @Resource
    private BaiduMapMapper baiduMapMapper;

    public Result getAllMapData() {
        HashMap<String, Object> hashMap = new HashMap();

        hashMap.put("pointsList", baiduMapMapper.getAllMapData());

        return Result.ok("true", 200, "成功", hashMap);
    }

    public Result getAllPointsInfo() {
        HashMap<String, Object> hashMap = new HashMap();
        List<AllPointsInfo> allPointsInfoList = baiduMapMapper.getAllPointsInfo();
        List<AllPointsInfoReturn> InfoReturnList = new ArrayList<>();

        for (AllPointsInfo allPointsInfo : allPointsInfoList) {
            AllPointsInfoReturn allPointsInfoReturn = new AllPointsInfoReturn(allPointsInfo, "false");
            InfoReturnList.add(allPointsInfoReturn);
        }

        hashMap.put("pointsInfo", InfoReturnList);

        return Result.ok("true",200,"成功",hashMap);
    }
}
